package com.zr.task.activity;

import android.content.Intent;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewTreeObserver;
import android.widget.EditText;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;

import com.zh.baselibrary.base.BaseActivity;
import com.zh.baselibrary.base.BaseNoIMActivity;
import com.zh.baselibrary.base.BasePresenter;
import com.zh.baselibrary.utils.BarUtil;
import com.zh.baselibrary.utils.LogUtils;
import com.zh.baselibrary.views.ToastView;
import com.zr.task.R;
import com.zr.task.utils.ScreenUtils;

import butterknife.BindView;
import butterknife.OnClick;

public class AdminLoginActivity extends BaseActivity {
    @BindView(R.id.et_pwd)
    EditText mEtPwd;
    @BindView(R.id.layout)
    RelativeLayout layout;


    @Override
    protected int getLayoutId() {
        return R.layout.admin_login_activity;
    }

    @Override
    protected void init() {
        mEtPwd.setOnFocusChangeListener(new android.view.View.
                OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                Drawable drawableLeft;
                if (hasFocus) {
                    drawableLeft = getResources().getDrawable(
                            R.drawable.password_active);

                } else {
                    drawableLeft = getResources().getDrawable(
                            R.drawable.password_default);

                }
                mEtPwd.setCompoundDrawablesWithIntrinsicBounds(drawableLeft,
                        null, null, null);
                mEtPwd.setCompoundDrawablePadding(4);
            }
        });
     //   ScreenUtils.addLayoutListener(layout, textView);
    }

    @Override
    protected BasePresenter createPresenter() {
        return null;
    }

    @OnClick({R.id.tv_cancel, R.id.tv_sure})
    public void onViewClicked(View view) {
        if (view.getId() == R.id.tv_cancel)
            finish();
        else {
            String password = mEtPwd.getText().toString();

            if (TextUtils.isEmpty(password)) {
                ToastView.showLong("请输入密码");
            } else {
                if (password.equals("zhongrui123@#")) {
                    BarUtil.showBar();
                    finish();
                    Intent intent = new Intent();// 为Intent设置Action、Category属性
                    intent.setAction(Intent.ACTION_MAIN);// "android.intent.action.MAIN"
                    intent.addCategory(Intent.CATEGORY_HOME); //"android.intent.category.HOME"
                    startActivity(intent);
                } else {
                    ToastView.showLong("密码错误");
                }
            }
        }
    }
}
